import os, cgi, time, string
import urllib2, logging, base64
from django.utils import simplejson
from google.appengine.ext import webapp
from base import BaseRequestHandler        

class ProfileHandler(BaseRequestHandler):
    def get(self):
       view_vals = self.get_token_or_show_login()
       if self.logged_in == True: 
           query = gdata.health.service.HealthProfileQuery(service='h9', params=params)
           #logging.info("ProfileQueryURI is %s"%query.ToUri())
           profile_feed = self.client.GetProfileFeed(query)
           view_vals['profile_feed'] = "nothing yet"
           view_vals['health_info'] = "ccr_json"
           self.render_response('profiles', view_vals) 

class MapHandler(BaseRequestHandler):
   def get(self):
      view_vals = {}
      view_vals['profile_feed'] = "option 1 stuff"
      view_vals['health_info'] = " other info"
      self.render_response('map', view_vals)
                                                 
class BrowseHandler(BaseRequestHandler):
   def get(self):
       view_vals = self.get_token_or_show_login()
       if self.logged_in == True:
           view_vals['profile_feed'] = "option 2 stuff"
           view_vals['health_info'] = "other info"
           self.render_response('browse', view_vals)                                                     

class AboutHandler(BaseRequestHandler):
  def get(self):
     view_vals = {}
     self.render_response('about', view_vals)

class MobileHandler(BaseRequestHandler):
   def get(self):
      view_vals = {}
      self.render_response('mobile', view_vals)
                                                     
class ShowPublicHandler(BaseRequestHandler):
    def get(self):
        view_vals = {}
        self.render_response('index_public', view_vals) 

class LogoutHandler(BaseRequestHandler): 
    def get(self):
        view_vals = self.get_token_or_show_login()
        self.clear_session()
        self.redirect('/')      
      
class StaticConditionHandler(BaseRequestHandler):
    def get(self):
       view_vals = {}
       sample = [{"status": "Active", "actor_role": "null", "code": "9.102", "treated_by": "janetcbrownstone@gmail.com", "name": "Abdominal Cramps"}, 
                 {"status": "ACTIVE", "actor_role": "null", "code": "461.9", "treated_by": "janetcbrownstone@gmail.com", "name": "Acute Sinusitis"}, 
                 {"status": "RESOLVED", "actor_role": "null", "code": "461.9", "treated_by": "janetcbrownstone@gmail.com", "name": "Acute Sinusitis"}, 
                 {"status": "ACTIVE", "actor_role": "null", "code": "3063", "treated_by": "janetcbrownstone@gmail.com", "name": "Insomnia"}, 
                 {"status": "ACTIVE", "actor_role": "null", "code": "3063", "treated_by": "janetcbrownstone@gmail.com", "name": "Insomnia"}, 
                 {"status": "ACTIVE", "actor_role": "null", "code": "595", "treated_by": "janetcbrownstone@gmail.com", "name": "Type 1 Diabetes"}, 
                 {"status": "ACTIVE", "actor_role": "null", "code": "595", "treated_by": "janetcbrownstone@gmail.com", "name": "Type 1 Diabetes"}] 
                 
       view_vals['values'] = sample
       self.render_response('json', view_vals)        
       